import React from 'react';
import { Main } from './home/Main';
import { Message } from './home/Message';
import { Servicer } from './home/Servicer';
import { Mine } from './home/Mine';
import { NavBar, Icon,TabBar } from 'antd-mobile';
import { authPromise }from '../api/user';
import {
    Route,
    withRouter,
    Redirect
} from 'react-router-dom';

import '../style/component/Home.less';
class HomePage extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            selectedTab:'main'
        }
        //this.handleTabSelected = this.handleTabSelected.bind(this)
    }
    //生命周期函数，组件第一次被渲染到Dom中，mount(挂载)
    componentDidMount() {
        // authPromise().then((res)=>{
        //     console.log(res);
        //     console.log("enen>>>>????",this.props)
        // })
    }
    handleTabSelected(value){   
        this.setState({'selectedTab': value})
        console.log("shenmm",this.props)
    }
    render(){
        return(
                <div className="homePage">
                    {/* <NavBar
                        mode="light"
                        // icon={<Icon type="left" />}
                        onLeftClick={() => this.props.history.push('/')}
                        >
                        浙有数
                    </NavBar> */}
                    {/* <div class="content">
                        <Route path={`${this.props.match.url}/left`}  component={Demo} />
                        <Route path={`${this.props.match.url}/middle`}  component={Index} />
                        <Route path={`${this.props.match.url}/right`}  component={Right} />
                    </div> */}
                    <TabBar
                        unselectedTintColor="#949494"
                        tintColor="#33A3F4"
                        barTintColor="#EAEAEA"
                        tabBarPosition="bottom"
                    >
                        <TabBar.Item
                            title="首页"
                            key="main"
                            selected={this.state.selectedTab === 'main'}
                            onPress={this.handleTabSelected.bind(this,'main')}
                            icon={<i className='iconfont iconshouye tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconshouye tabIconfont'></i>}
                        >
                            <Main></Main>
                        </TabBar.Item>
                        <TabBar.Item
                            title="消息"
                            key="message"
                            selected={this.state.selectedTab === 'message'}
                            onPress={this.handleTabSelected.bind(this,'message')}
                            icon={<i className='iconfont iconxiaoxi4 tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconxiaoxi4 tabIconfont'></i>}
                        >
                           <Message></Message>
                        </TabBar.Item>
                        <TabBar.Item
                            title="客服"
                            key="servicer"
                            selected={this.state.selectedTab === 'servicer'}
                            onPress={this.handleTabSelected.bind(this,'servicer')}
                            icon={<i className='iconfont iconkefu tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconkefu tabIconfont'></i>}
                        >
                           <Servicer></Servicer>
                        </TabBar.Item>
                        <TabBar.Item
                            title="我的"
                            key="mine"
                            selected={this.state.selectedTab === 'mine'}
                            onPress={this.handleTabSelected.bind(this,'mine')}
                            icon={<i className='iconfont iconrenshu tabIconfont'></i>}
                            selectedIcon={<i className='iconfont iconrenshu tabIconfont'></i>}
                        >
                            <Mine></Mine>
                        </TabBar.Item>
                    </TabBar>
                </div>
        )
    }
}


export default withRouter(HomePage);